﻿using System;
using System.Runtime.Remoting.Messaging;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using Cfg.Proxies;
using NUnit.Framework;

namespace Cfg.Test.IAppConfigTests
{
    [TestFixture]
    public class ScopeTest
    {
        public interface ITestConfig
        {
             string Foo { get; }
        }


        [Test]
        public void Test()
        {
            AppSettings.Init<ITestConfig>();
            var cfg = AppSettings.Get<ITestConfig>();

            Assert.IsNull(cfg.Foo);

            using (var scope = new CfgScope<ITestConfig>())
            {
                scope.Override(x => x.Foo, "test");

                var t = new Thread(() =>
                {
                    Console.WriteLine(cfg.Foo == null);
                });
                t.Start();

                Assert.AreEqual("test", cfg.Foo);
            }

            Assert.IsNull(cfg.Foo);
        }
    }
}